func minimumTotal(triangle [][]int) int {
	m := len(triangle)
	dp := make([][]int, m+1)
	ans := math.MaxInt32
	//建dp,花费O(n^2)
	for i := range dp {
		dp[i] = make([]int, m+1)
		for j := range dp[i] {
			dp[i][j] = math.MaxInt32
		}
	}
	dp[0][0] = 0
	//遍历triangle同时更新dp数组,O(n^2)
	for i := 1; i <= m; i++ {
		for j := 1; j <= i; j++ {
			dp[i][j] = min(dp[i-1][j-1], dp[i-1][j]) + triangle[i-1][j-1]
		}
	}
	//遍历dp最后一行，更新ans,O(n)
	for j := 1; j <= m; j++ {
		ans = min(ans, dp[m][j])
	}
	return ans
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
